<template>
  <div class="bc-menu">
    <div class="menu-item">
      <span class="item blue" v-for="(item,index) in menu" :class="{'active': currentIndex==index}" :key="index" @click="selectMenu(item, index)">{{item.name}}</span>
    </div>
    <div class="menu-item-se">
      <div class="se-li" v-for="(item, index) in list" :key="index">
        <div class="title">
          <span class="s-name">{{item.name}}</span>
          <img v-if="currentMenu==index" src="../../../assets/icon/reduce.png" alt="" @click="collspaA(item,index)">
          <img v-else src="../../../assets/icon/add.png" @click="collspaR(item,index)" alt="">
        </div>
        <div class="child-li" v-show="currentMenu==index">
          <div class="li-mod" v-for="(mod, i) in item.subObjs" :key="i" :class="{'active': i ==currentActive }"><span @click="view3D(mod, i)">{{mod.title}}</span></div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "headBar",
  computed: {
  },
  data () {
    return {
      currentIndex: 0,
      currentMenu: 0,
      currentPage: 1,
      pageSize: 5,
      currentActive: 0,
      cIndex: 0,
      list: [],
      vList: [],
      menu: [{
        name: '创优71条',
        path: '/installer/excellence/index'
      }]
    }
  },
  components: {
  },
  mounted () {
  },
  created () {
    // this.queryBimCategory()
    this.CY71Categorys()
  },
  methods: {
    selectMenu (item, index) {
      this.currentIndex = index
      this.currentActive = 0
      this.cIndex = 0
      this.currentPage = 1
      // this.$router.push({ path: item.path })
      if (this.currentIndex) {
        this.$router.push({ path: `/installer/bim/case?id=${this.vList[0].id}` })
      } else {
        this.$router.push({ path: `/installer/bim/3d/${this.list[0].subObjs[0].fieldId}?name=${this.list[0].subObjs[0].fileName}` })
      }
    },
    changePage (page = 0) {
      if (page) {
        if (this.currentPage < 1) {
          return false
        } else {
          this.currentPage = this.currentPage - 1
        }
      } else {
        if (this.currentPage >= Math.ceil(this.vList.length / 5)) {
          return false
        } else {
          this.currentPage = this.currentPage + 1
        }
      }
      this.cIndex = 0
      this.$router.push({ path: `/installer/bim/case?id=${this.currentList[0].id}` })
    },
    queryBimVideo () {
      this.$http.queryBimVideo({}).then(res => {
        this.vList = res.data
      })
    },
    CY71Categorys () {
      this.$http.CY71Categorys({}).then(res => {
        this.list = res.data
        if (this.list && this.list.length && this.list[0].subObjs && this.list[0].subObjs.length) {
          this.$router.push({ path: `/installer/excellence/index/${this.list[0].subObjs[0].id}` })
        }
      })
    },
    collspaA (item, index) {
      this.currentMenu = -1
    },
    collspaR (item, index) {
      this.currentMenu = index
    },
    view3D (item, i) {
      this.currentActive = i
      this.$router.push({ path: `/installer/excellence/index/${item.id}` })
    }
  }
}

</script>

<style lang="scss">
</style>
